package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

@SuppressWarnings("serial")
public class Menu extends JMenuBar{

	JMenu fileMenu = null;
	JMenu actionMenu = null;
	JMenu optionMenu = null;
	JMenu aboutMenu = null;
	
	
	public Menu(){
		super();
		initalize();
	}
	
	private void initalize(){
		this.add(getFileMenu());
		this.add(getActionMenu());
		this.add(getOptionMenu());
		this.add(getAboutMenu());
	}
	
	private JMenu getFileMenu(){
		if (fileMenu == null){
			fileMenu = new JMenu("File");
			JMenuItem newBase = new JMenuItem("New");
			JMenuItem load = new JMenuItem("Load");
			JMenuItem save = new JMenuItem("Save");
			JMenuItem exit = new JMenuItem("Exit");
			exit.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					System.exit(0);	
				}
			});
			fileMenu.add(newBase);
			fileMenu.addSeparator();
			fileMenu.add(load);
			fileMenu.add(save);
			fileMenu.addSeparator();
			fileMenu.add(exit);
		}
		return fileMenu;
	}
	
	private JMenu getActionMenu(){
		if (actionMenu == null){
			actionMenu = new JMenu("Actions");
			JMenuItem addCountry = new JMenuItem("Add Country");
			JMenuItem editCountry = new JMenuItem("Edit Country");
			JMenuItem removeCountry = new JMenuItem("Remove Country");
			JMenuItem addLeague = new JMenuItem("Add League");
			JMenuItem editLeague = new JMenuItem("Edit League");
			JMenuItem removeLeague = new JMenuItem("Remove League");
			JMenuItem addClub = new JMenuItem("Add Club");
			JMenuItem editClub = new JMenuItem("Edit Club");
			JMenuItem removeClub = new JMenuItem("Remove Club");
			JMenuItem addPlayer = new JMenuItem("Add Player");
			JMenuItem editPlayer = new JMenuItem("Edit Player");
			JMenuItem RemovePlayer = new JMenuItem("Remove Player");
			actionMenu.add(addCountry);
			actionMenu.add(editCountry);
			actionMenu.add(removeCountry);
			actionMenu.addSeparator();
			actionMenu.add(addLeague);
			actionMenu.add(editLeague);
			actionMenu.add(removeLeague);
			actionMenu.addSeparator();
			actionMenu.add(addClub);
			actionMenu.add(editClub);
			actionMenu.add(removeClub);
			actionMenu.addSeparator();
			actionMenu.add(addPlayer);
			actionMenu.add(editPlayer);
			actionMenu.add(RemovePlayer);
		}
		return actionMenu;
	}
	
	private JMenu getOptionMenu(){
		if (optionMenu == null){
			optionMenu = new JMenu("Options");
			JMenuItem preferences = new JMenuItem("preferences");
			optionMenu.add(preferences);
		}
		return optionMenu;
	}
	
	private JMenu getAboutMenu(){
		if (aboutMenu == null){
			aboutMenu = new JMenu("About");
			JMenuItem help = new JMenuItem("Help");
			JMenuItem about = new JMenuItem("About");
			aboutMenu.add(help);
			aboutMenu.addSeparator();
			aboutMenu.add(about);
			
		}
		return aboutMenu;
	}
}
